package com.qumitech.visualnovel.service.pay;

import com.alibaba.fastjson.JSONObject;
import com.qumitech.visualnovel.datasource.console.DailyRechargeDataDOMapper;
import com.qumitech.visualnovel.model.dao.console.DailyRechargeDataV2DO;
import com.qumitech.visualnovel.model.dao.console.RechargeTransferDataDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class RechargeServiceImpl implements RechargeService {
    @Autowired
    DailyRechargeDataDOMapper dailyRechargeDataDOMapper;

    @Override
    public JSONObject getRechargeDailyStatistics(String startTime, String endTime, String geoName, String channel, Integer offset, Integer limit) {
        List<DailyRechargeDataV2DO> items = dailyRechargeDataDOMapper.getRechargeDailyStatistics(startTime, endTime, geoName, channel, offset, limit);
        int count = dailyRechargeDataDOMapper.countRechargeDailyStatistics(startTime, endTime, geoName, channel);

        JSONObject jsonObj = new JSONObject();
        jsonObj.put("count", count);
        jsonObj.put("items", items);
        return jsonObj;
    }

    @Override
    public JSONObject getRechargeTransferStatistics(String startTime, String endTime, List<Integer> bookIds, String bookTitle, String geoName, String channel, Integer offset, Integer limit) {
        List<RechargeTransferDataDO> items = dailyRechargeDataDOMapper.getRechargeTransferStatistics(startTime, endTime, bookIds, bookTitle, geoName, channel, offset, limit);
        int count = dailyRechargeDataDOMapper.countRechargeTransferStatistics(startTime, endTime, bookIds, bookTitle, geoName, channel);

        JSONObject jsonObj = new JSONObject();
        jsonObj.put("count", count);
        jsonObj.put("items", items);
        return jsonObj;
    }


}
